<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        .box {
            width: 300px;
            height: 200px;
            padding-top: 100px;
            background-color: gray;
            margin: 100px;
            text-align: center;
            font: 18px/30px '';
            cursor: pointer;
        }
    </style>
</head>
<body>
<div class="box">

</div>
<script src="animate.js"> </script>
<script>
var div = document.getElementsByTagName('div')[0];

div.onmousemove = function (event) {
    event = event || window.event;

    var pagex = event.pageX || scroll().left+event.clientX,
        pagey = event.pageY || scroll().top + event.clientY;

    var xx = div.offsetLeft;
    var yy = div.offsetTop;
    var targetx = pagex - xx ;
    var targety = pagey - yy;
    this.innerHTML = "鼠标在盒子中的X坐标为："+targetx+"px;<br>鼠标在盒子中的Y坐标为："+targety+"px;"
}
</script>
</body>
</html>